package com.integrance.budgetapp.dao;

import java.io.Serializable;
import java.util.List;

/**
 * This interface defines the CRUD methods for a generic DAO.
 * 
 * @author Octavian Cismasu
 *
 * @param <T>
 * @param <PK>
 */
public interface GenericDao<T, PK extends Serializable> {

	/** Persist the newInstance object into database */
	PK create(T newInstance);

	/**
	 * Retrieve an object that was previously persisted to the database using
	 * the indicated id as primary key
	 */
	T findById(PK id);
	
	/** Find the persistent entity corresponding to the <tt>exampleInstance</tt> */
	List<T> findByExample(T exampleInstance);
	
	/** Retrieve all entity objects of type <tt>T</tt> */
	List<T> findAll();

	/** Make modifications to object persistent */
	void saveOrUpdate(T transientObject);
	
	/** Remove an object from persistent storage in the database */
	void delete(T persistentObject);
}
